﻿package view.popup
{
    import com.core.*;
    import com.sh.game.global.*;
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.instances.*;
    import view.mornExtends.*;
    import vo.*;

    public class EmsFailView extends View implements IDialogUI
    {
        public var closeBtn:Button;
        public var list:List;
        public var sureBtn:Button;
        public var txt_desc:Label;
        protected var uiXML:XML;
        private var cfgItem:Object;
        private var background:Sprite;

        public function EmsFailView()
        {
            this.uiXML = <View>r
n	t	t	t  <Image url=""png.common.cs2_tsbg"" x=""0"" y=""0""/>r
n	t	t	t  <Button skin=""png.common.btn_cs2_close"" x=""249"" y=""5"" var=""closeBtn""/>r
n	t	t	t  <Image url=""png.common.cs2_di3nei"" x=""10"" y=""39"" width=""265"" height=""108"" sizeGrid=""10,10,10,10""/>r
n	t	t	t<Label text=""本次护送失败，请再接再励！"" x=""66"" y=""52"" color=""0xff0000"" font=""SimSun"" stroke=""1"" var=""txt_desc""/>r
n	t	t	t  <List x=""72"" y=""76"" repeatX=""2"" spaceX=""30"" var=""list"">r
n	t	t	t	t<FlashItem name=""render"">r
n	t	t	t	t  <Image url=""png.common.cs2_di2nei""/>r
n	t	t	t	t  <Image url=""png.common.noramlicon"" x=""5"" y=""5"" width=""44"" height=""43"" name=""icon""/>r
n	t	t	t	t  <Label text=""label"" x=""10"" y=""32"" width=""42"" height=""18"" color=""0xffffff"" name=""count"" align=""right"" font=""SimSun""/>r
n	t	t	t	t</FlashItem>r
n	t	t	t  </List>r
n	t	t	t  <Button label=""确定"" skin=""png.common.btn_2"" x=""100"" y=""153"" labelFont=""SimSun"" labelStroke=""1"" var=""sureBtn"" labelColors=""0xff8b24,0xffd437,0xc56b1c""/>r
n	t	t	t</View>")("<View>
			  <Image url="png.common.cs2_tsbg" x="0" y="0"/>
			  <Button skin="png.common.btn_cs2_close" x="249" y="5" var="closeBtn"/>
			  <Image url="png.common.cs2_di3nei" x="10" y="39" width="265" height="108" sizeGrid="10,10,10,10"/>
			<Label text="本次护送失败，请再接再励！" x="66" y="52" color="0xff0000" font="SimSun" stroke="1" var="txt_desc"/>
			  <List x="72" y="76" repeatX="2" spaceX="30" var="list">
				<FlashItem name="render">
				  <Image url="png.common.cs2_di2nei"/>
				  <Image url="png.common.noramlicon" x="5" y="5" width="44" height="43" name="icon"/>
				  <Label text="label" x="10" y="32" width="42" height="18" color="0xffffff" name="count" align="right" font="SimSun"/>
				</FlashItem>
			  </List>
			  <Button label="确定" skin="png.common.btn_2" x="100" y="153" labelFont="SimSun" labelStroke="1" var="sureBtn" labelColors="0xff8b24,0xffd437,0xc56b1c"/>
			</View>;
            this.cfgItem = ConfigDictionary.data.item;
            return;
        }// end function

        override protected function createChildren() : void
        {
            createView(this.uiXML);
            this.init();
            return;
        }// end function

        public function init() : void
        {
            this.background = new Sprite();
            this.background.graphics.beginFill(0, 0.5);
            this.background.graphics.drawRect(0, 0, GlobalLayer.instance.root.stage.stageWidth, GlobalLayer.instance.root.stage.stageHeight);
            this.background.graphics.endFill();
            this.background.addEventListener(MouseEvent.MOUSE_DOWN, this.onDown);
            PluginManager.instance.alertContainer.addChild(this.background);
            var _loc_1:Boolean = false;
            this.visible = false;
            this.background.visible = _loc_1;
            this.x = GlobalLayer.instance.root.stage.stageWidth - this.width >> 1;
            this.y = GlobalLayer.instance.root.stage.stageHeight - this.height >> 1;
            this.closeBtn.clickHandler = new Handler(this.close);
            this.sureBtn.clickHandler = new Handler(this.close);
            return;
        }// end function

        public function show(param1:Object) : void
        {
            var _loc_3:Dictionary = null;
            var _loc_4:ItemSplit = null;
            var _loc_5:Array = null;
            var _loc_6:Object = null;
            var _loc_7:Object = null;
            var _loc_8:Number = NaN;
            var _loc_9:int = 0;
            var _loc_10:Object = null;
            var _loc_11:Object = null;
            var _loc_12:Object = null;
            var _loc_13:int = 0;
            var _loc_14:Object = null;
            var _loc_15:Boolean = true;
            this.background.visible = true;
            this.visible = _loc_15;
            var _loc_2:Array = [];
            switch(int(param1.type))
            {
                case 0:
                {
                    _loc_10 = ItemObject.create(this.cfgItem[4]);
                    _loc_10.count = param1.param[0];
                    _loc_11 = ItemObject.create(this.cfgItem[6]);
                    _loc_11.count = param1.param[1];
                    if (_loc_10.count > 0)
                    {
                        _loc_2.push(_loc_10);
                        ;
                    }
                    if (_loc_11.count > 0)
                    {
                        _loc_2.push(_loc_11);
                        ;
                    }
                    this.txt_desc.text = "本次护送失败，请再接再励！";
                    this.txt_desc.x = 66;
                    break;
                }
                case 1:
                {
                    _loc_12 = ModelProxy.getValue("data", "unionInfo");
                    _loc_13 = _loc_12.unionLevel;
                    _loc_3 = ConfigDictionary.data.unionEms;
                    _loc_4 = new ItemSplit();
                    _loc_5 = _loc_4.doSplits(_loc_3[_loc_13].reward, "/", "&", "#");
                    _loc_8 = 1;
                    this.txt_desc.text = "本次护送成功！";
                    this.txt_desc.x = 66;
                    if (param1.param == 0)
                    {
                        _loc_8 = 0.7;
                        this.txt_desc.text = "本次护送失败，请再接再励！";
                    }
                    for each (_loc_7 in _loc_5[0])
                    {
                        
                        (_loc_16[_loc_15]).count = _loc_7.count * _loc_8;
                        if (_loc_7.id == 4)
                        {
                            _loc_7.count = _loc_7.count * (1 + UserData.getUserData("level") / 5);
                        }
                        _loc_2.push(_loc_7);
                    }
                    break;
                }
                case 2:
                {
                    this.txt_desc.x = 30;
                    this.txt_desc.text = "恭喜你赢得沙巴克胜利";
                    _loc_3 = ConfigDictionary.data.unionEms;
                    _loc_14 = ConfigDictionary.data.sbkreward;
                    _loc_4 = new ItemSplit();
                    _loc_5 = _loc_4.doSplits(_loc_14[1].reward, "/", "&", "#");
                    _loc_8 = 1;
                    _loc_6 = ConfigDictionary.data.worldlevel;
                    _loc_9 = ModelProxy.getValue("data", "worldlevel");
                    for each (_loc_7 in _loc_5[0])
                    {
                        
                        (_loc_16[_loc_15]).count = _loc_7.count * _loc_6[_loc_9].win;
                        _loc_2.push(_loc_7);
                    }
                    break;
                }
                case 3:
                {
                    this.txt_desc.x = 30;
                    _loc_8 = 1;
                    this.txt_desc.text = "很遗憾你们未能攻占沙巴克，请再接再厉 ";
                    _loc_3 = ConfigDictionary.data.unionEms;
                    _loc_14 = ConfigDictionary.data.sbkreward;
                    _loc_4 = new ItemSplit();
                    _loc_5 = _loc_4.doSplits(_loc_14[2].reward, "/", "&", "#");
                    _loc_6 = ConfigDictionary.data.worldlevel;
                    _loc_9 = ModelProxy.getValue("data", "worldlevel");
                    for each (_loc_7 in _loc_5[0])
                    {
                        
                        (_loc_16[_loc_15]).count = _loc_7.count * _loc_6[_loc_9].lose;
                        _loc_2.push(_loc_7);
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            this.list.array = _loc_2;
            this.list.renderHandler = new Handler(this.listRender);
            return;
        }// end function

        private function listRender(param1:Component, param2:int) : void
        {
            if (param2 < this.list.length)
            {
                (param1 as FlashItem).data = this.list.array[param2];
            }
            return;
        }// end function

        private function onDown(event:MouseEvent) : void
        {
            event.stopImmediatePropagation();
            return;
        }// end function

        private function resizeHandler(event:Event) : void
        {
            this.background.width = GlobalLayer.instance.root.stage.stageWidth;
            this.background.height = GlobalLayer.instance.root.stage.stageHeight;
            this.x = GlobalLayer.instance.root.stage.stageWidth - this.width >> 1;
            this.y = GlobalLayer.instance.root.stage.stageHeight - this.height >> 1;
            return;
        }// end function

        public function close() : void
        {
            var _loc_1:Boolean = false;
            this.visible = false;
            this.background.visible = _loc_1;
            return;
        }// end function

    }
}
